﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ThanhTu.GNC.Media.KQXS.DataAccess.DAL;
using ThanhTu.GNC.Media.KQXS.DataAccess.DO;

namespace GNCMedia.KQXS.Admin
{
    public partial class AddNewSyntax : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    ProvinceDAL province = new ProvinceDAL();
                    List<ProvinceDO> alldata = province.selectadd();

                    ddl_IDtinh_Syntax.DataSource = alldata;
                    ddl_IDtinh_Syntax.DataTextField = "princeName";
                    ddl_IDtinh_Syntax.DataValueField = "provinceID";
                    ddl_IDtinh_Syntax.DataBind();
                }
                catch (Exception ex)
                {
                    Response.Write("Error load province at Add New Syntax:" + ex);
                }
                finally
                {
                        
                }
            }
        }

        protected void btn_addNewData_Click1(object sender, EventArgs e)
        {
           MessengerSyntaxDAL messengerSyntax = new MessengerSyntaxDAL();
            MessengerSyntaxDO messengerDO = new MessengerSyntaxDO();
            messengerDO.ProvinceID = ddl_IDtinh_Syntax.SelectedValue;
            messengerDO.Syntax = txt_Syntax.Text;
            messengerDO.SwitchBoard = txt_tongDai_Syntax.Text;
            int checkInsert = messengerSyntax.SaveMess(messengerDO);
            if (checkInsert > 0)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowStatus", "javascript:alert('Thêm Mới CÚ PHÁP Tin Nhắn Thành công);", true);
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowStatus", "javascript:alert('LỖI THÊM MỚI CÚ PHÁP ,XIN VUI LÒNG THỬ LẠI);", true);
            }
        }
    }
}